<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
	<head>
		<th:block
th:include="themes/bobey/blog_include :: blogHeader(title=${blogConfig['blog.config.title'].configValue},
keywords=${blogConfig['blog.config.keywords'].configValue},
description=${blogConfig['blog.config.description'].configValue},
blogConfig=${blogConfig})" />
	</head>
	<body>
		<th:block th:include="themes/bobey/blog_include::menu(menus=${menus},blogConfig=${blogConfig})" />
		<!-- 主体部分 -->
		<section class="bobey-main-box">
			<div class="layui-row ">
				<div class="layui-col-md9  bobey-left-box" id="miao-left">
					<div class="bobey-left-content">
					<th:block th:include="themes/bobey/blog_include::blogArticle(post=${post},comments=${comments})" />
					</div>
				</div>

				<!-- 主体部分右边 -->
				<div class="layui-col-md3 bobey-right-box">
				<th:block th:include="themes/bobey/blog_include::rightCommen"/>
				</div>
			</div>

		</section>

		<!-- 底部导航 -->
		<th:block th:include="themes/bobey/blog_include::bottom" />
		<th:block th:include="themes/bobey/blog_include::footer_js" />

		<script th:inline="JavaScript">
            layui.use(['element', 'carousel', 'layer','layedit'], function() {
                var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
                var layer = layui.layer;
                var carousel = layui.carousel;
                var layedit = layui.layedit;

                function toLogin() {
                    layer.confirm('你还未登陆!', {
                        btn: ['登陆','取消'] //按钮
                    }, function(){
                        location.href = ctx + 'blog/user/login';
                    }, function(){
                        layer.close();
                    });
                }
         //点赞，踩，分享，收藏，评分
         const lookUrl = ctx + "blog/record/addLookRecord", likeUrl = ctx + "blog/record/addLikeRecord",
             nastyUrl = ctx + "blog/record/addNastyRecord"
             , shareUrl = ctx + "blog/record/addShareRecord", scoreUrl = ctx + "blog/record/addScoreRecord",
             collectUrl = ctx + "blog/record/addCollectRecord",
             commentUrl = ctx + "comment",
             userUrl = ctx + "blog/user";
         const userId=$('#userId').val();
         const postRecord = {
             lookRecord: function () {
                 this.ajaxPost();
             },
             likeRecord: function () {

             },
             nastyRecord: function () {

             },
             shareRecord: function () {

             },
             scoreRecord: function () {

             },
             collectRecord: function () {

             },
             ajaxPost: function (url, data, callback) {
                 $.post(url, data, function (result) {

                 });
             }
         };
         $.post(lookUrl,{articleId:$("#articleId").val()},function(result){

		 });
		$("#post-like").click(function () {
		    if (userId=='')
            {
               toLogin();
            }
		    else{
			$.post(likeUrl,{articleId:$("#articleId").val()},function(result){
                 layer.msg(result.msg);
			});
            }
		});
		 $("#post-nasty").click(function () {
             if (userId=='')
             {
                 toLogin();
             }
             else {
                 $.post(nastyUrl, {articleId: $("#articleId").val()}, function (result) {
					 layer.msg(result.msg);
                 });
             }
		 });


			$(document).ready(function() {
				var tags = [[${tags}]],entries = [];
				$.each(tags, function(index, element) {
					entries.push({
						label: element.tagName,
						url: [[${blogConfig['blog.config.index'].configValue}]]+"/tag/"+element.tagId,
						target: '_top'
					})
				});

				var settings = {
					entries: entries,
					width: $('#bobey-tags').width(),
					height: $('#bobey-tags').width(),
					radius: '60%',
					radiusMin: 75,
					bgDraw: true,
					bgColor: '#494A5F',
					opacityOver: 1.00,
					opacityOut: 0.05,
					opacitySpeed: 6,
					fov: 800,
					speed: 0.5,
					fontFamily: 'Oswald, Arial, sans-serif',
					fontSize: '15',
					fontColor: '#fff',
					fontWeight: 'normal', //bold
					fontStyle: 'normal', //italic 
					fontStretch: 'normal', //wider, narrower, ultra-condensed, extra-condensed, condensed, semi-condensed, semi-expanded, expanded, extra-expanded, ultra-expanded
					fontToUpperCase: true
				};

				//var svg3DTagCloud = new SVG3DTagCloud( document.getElementById( 'holder'  ), settings );
				$('#tag-cloud').svg3DTagCloud(settings);

			});
			//编辑器索引
				var ind ;
				
				$(".comment-ok").click(function () {
					var commentData= $(this).data().comment.split(",");// 在每个逗号(,)处进行分解。
					var dataObj={'parentId':commentData[0],'articleId':commentData[1],'replyBy':commentData[2],'fromBy':userId};
					if(userId=='')
					{
						toLogin();
					}
					else {
                        $.get(userUrl+"/isLogin/"+userId,function(result){
                            if(result.code==0)
                            {
                                layer.open({
                                    type: 1,
                                    title:'评论',
                                    closeBtn: 0, //不显示关闭按钮
                                    anim: 2,
                                    area: '340px',
                                    offset: '100px',
                                    shadeClose: true, //开启遮罩关闭
                                    content: '<div ><textarea id="demo" style="display: none;"></textarea></div>' ,
                                    success: function(layero, index){
                                        ind=layedit.build('demo',{
                                            tool: [
                                                'strong' //加粗
                                                ,'italic' //斜体
                                                ,'underline' //下划线
                                                ,'del' //删除线
                                                ,'|' //分割线
                                                ,'left' //左对齐
                                                ,'center' //居中对齐
                                                ,'right' //右对齐
                                                ,'link' //超链接
                                                ,'unlink' //清除链接
                                            ]
                                        }); //建立编辑器
                                    },
                                    btn: ['取消','评论'],
                                    yes: function(index, layero){
                                        layer.close(index);
                                    } ,
                                    btn2: function(index, layero){
                                        var content=layedit.getContent(ind);
                                        if(content=='')
                                        {
                                            layer.msg("评论不能为空！");
                                        }
                                        else {
                                            dataObj['content']=content;
                                            $.post(commentUrl+"/add",dataObj,function(result){
                                                if(result.code==0)
                                                {
                                                    location.reload();
                                                }
                                                else{
                                                    layer.msg(result.msg);
                                                }
                                            })
                                        }
                                    },
                                });
                            }
                            else{
                                location.reload();
                            }
                        })
					}
					});

              //屏幕改变刷新
				window.onresize = function() {
					location.reload();
				}

				$(".bobey-aside-button").click(function() {
					$(".bobey-nav-aside").css("display", "block");

					if ($(".bobey-nav-aside").hasClass("slideInDown")) {

						$(".bobey-nav-aside").removeClass("slideInDown");
						$(".bobey-nav-aside").addClass("slideOutUp");
						$("body").css("overflow-y", "auto");
					} else {

						$(".bobey-nav-aside").removeClass("slideOutUp");
						$(".bobey-nav-aside").addClass("slideInDown");
						$("body").css("overflow-y", "hidden");

					}

				});
			});
			$(".side_con>li").mousemove(function() {
				$(".side_con>li").removeClass("on");
				$(this).addClass("on");
			})
			// grab an element
			var elem = document.querySelector("nav");
			var headroom = new Headroom(elem, {
				"tolerance": 5,
				"offset": 205,
				"classes": {
					"initial": "animated",
					"pinned": "slideInDown",
					"unpinned": "slideOutUp"
				}
			});
			headroom.init();
		</script>
	</body>

</html>
